<template>
	<jk-dialog
		v-model="showDialog"
		title="工艺详情"
		width="1100px"
		:show-content-loading="showLoading"
		append-to-body
		:show-close-btn="true"
		:show-cancel-btn="false"
		:show-confirm-btn="false"
		@on-close="onVisibleChange(false)"
		@on-visible-change="onVisibleChange"
	>
		<el-form ref="ruleForm" :model="ruleForm" label-width="110px" :show-message="false">
			<div ref="box1">
				<div class="flex-between-center margin-bottom-10">
					<el-tag type="primary" effect="plain">
						<span class="el-icon-tickets item-gap"></span>
						<span>基本信息</span>
					</el-tag>
				</div>
				<el-row ref="box1">
					<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
						<el-form-item class="margin-bottom-10" label="单据编号">
							<span class="read-only-2">{{ ruleForm.code }}</span>
						</el-form-item>
					</el-col>
					<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
						<el-form-item class="margin-bottom-10" label="单据日期">
							<span class="read-only-2">{{ ruleForm.specDate }}</span>
						</el-form-item>
					</el-col>
					<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
						<el-form-item class="margin-bottom-10" label="纺纱方式">
							<span class="read-only-2">{{ ruleForm.spinTypeName }}</span>
						</el-form-item>
					</el-col>
					<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
						<el-form-item class="margin-bottom-10" label="工序">
							<span class="read-only-2">{{ ruleForm.processName }}</span>
						</el-form-item>
					</el-col>
					<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
						<el-form-item class="margin-bottom-10" label="品种名称">
							<span class="read-only-2">{{ ruleForm.productName }}</span>
						</el-form-item>
					</el-col>
					<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
						<el-form-item class="margin-bottom-10" label="批号">
							<span class="read-only-2">{{ ruleForm.batchCode }}</span>
						</el-form-item>
					</el-col>
					<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
						<el-form-item class="margin-bottom-10" label="工艺员">
							<span class="read-only-2">{{ ruleForm.specEmpName }}</span>
						</el-form-item>
					</el-col>
				</el-row>
			</div>
			<div ref="box2">
				<el-tag type="primary" effect="plain" class="margin-bottom-10">
					<span class="el-icon-paperclip item-gap"></span>
					<span>工艺信息</span>
				</el-tag>
				<el-row>
					<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
						<el-form-item class="margin-bottom-10" label="设备机型">
							<span class="read-only-2">{{ ruleForm.machineModelName }}</span>
						</el-form-item>
					</el-col>
					<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
						<el-form-item class="margin-bottom-10" label="台日单产">
							<span class="read-only-2">{{ ruleForm.dailyYield }}</span>
						</el-form-item>
					</el-col>
					<!--<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
						<el-form-item class="margin-bottom-10" label="公定回潮率%">
							<span class="read-only-2">{{ ruleForm.moistureRegain }}</span>
						</el-form-item>
					</el-col>
					<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
						<el-form-item class="margin-bottom-10" label="运转效率%">
							<span class="read-only-2">{{ ruleForm.efficiencyPercent }}</span>
						</el-form-item>
					</el-col>-->
					<el-col :xl="6" :lg="8" :md="12" :sm="12" :xs="24">
						<el-form-item class="margin-bottom-10" label="定量(g/m)">
							<div class="flex-start">
								<span class="read-only-2">{{ ruleForm.gramWeight }}</span>
								<span>~</span>
								<span class="read-only-2">{{ ruleForm.meters }}</span>
							</div>
						</el-form-item>
					</el-col>
				</el-row>
			</div>
			<el-tag ref="box3" type="primary" effect="plain" class="margin-bottom-10">
				<span class="el-icon-notebook-2 item-gap"></span>
				<span>工艺项目</span>
			</el-tag>
			<el-row>
				<el-col :span="24">
					<jk-table ref="jkTable" v-loading="tableLoading" :data="tableData" border :height="dialogTableHeight - 10" style="width: 100%">
						<vxe-table-column type="seq" title="序号" width="70" align="center" />
						<vxe-table-column field="specParamName" title="工艺项目" :min-width="140"></vxe-table-column>
						<vxe-table-column field="val" title="标准值" align="right" :min-width="120">
							<template slot-scope="scope">
								<span>{{ scope.row.val }}</span>
							</template>
						</vxe-table-column>
						<vxe-table-column field="valMin" title="下限值" align="right" :min-width="120">
							<template slot-scope="scope">
								<span>{{ scope.row.valMin }}</span>
							</template>
						</vxe-table-column>
						<vxe-table-column field="valMax" title="上限值" align="right" :min-width="120">
							<template slot-scope="scope">
								<span>{{ scope.row.valMax }}</span>
							</template>
						</vxe-table-column>
						<!--<vxe-table-column field="paramType" title="项目类型" :width="100" align="center">
							<template slot-scope="scope">
								{{ scope.row.paramsType === 1 ? '设备工艺' : '运转工艺' }}
							</template>
						</vxe-table-column>
						<vxe-table-column field="ifNull" title="是否为空" :width="100" align="center">
							<template slot-scope="scope">
								{{ scope.row.ifNull ? '是' : '否' }}
							</template>
						</vxe-table-column>
						<vxe-table-column field="ifBusi" title="是否翻改项目" :width="100" align="center">
							<template slot-scope="scope">
								{{ scope.row.ifBusi ? '是' : '否' }}
							</template>
						</vxe-table-column>
						<vxe-table-column field="dataType" title="数据类型" :width="100" align="center">
							<template slot-scope="scope">
								{{ scope.row.dataType === 1 ? '数字' : '字符' }}
							</template>
						</vxe-table-column>-->
					</jk-table>
				</el-col>
			</el-row>
		</el-form>
	</jk-dialog>
</template>

<script>
    import calHeight from '/src/mixins/cal-dialog-height';
    import { spinSpecSheetGet } from '../../../api/technology/order';
    export default {
        props: {
            dialogState: {
                type: Boolean,
                default: false
            },
            dataId: {
                type: [String, Number],
                default: ''
            }
        },
        mixins: [calHeight],
        data() {
            return {
                pageType: 'detail',
                tableLoading: false,
                showDialog: false,
                showLoading: true,
                tableData: [],
                ruleForm: {},
                selectItem: {}
            };
        },
        methods: {
            onVisibleChange(e) {
                this.$emit('on-visible-change', e);
                if (!e) {
                    Object.assign(this.$data, this.$options.data());
                    this.$nextTick(() => {
                        this.$refs['ruleForm'].clearValidate([]);
                        this.$refs.ruleForm.resetFields();
                    });
                }
            },
            getDetailRequest() {
                return spinSpecSheetGet({ id: this.dataId }).then(res => {
                    if (res.data.status === 200) {
                        const resData = JSON.parse(JSON.stringify(res.data.res));
                        this.ruleForm = resData;
                        this.tableData = res.data.res.specSheetParamList.map(x => {
                            x.val = x.dataType === 1 ? Number(x.val) : x.val;
                            x.valMax = x.dataType === 1 ? Number(x.valMax) : x.valMax;
                            x.valMin = x.dataType === 1 ? Number(x.valMin) : x.valMin;
                            return x;
                        });
                    }
                });
            },
            async getDependentData() {
                this.showLoading = true;
                if (this.dataId) {
                    await this.getDetailRequest();
                }
                this.showLoading = false;
            }
        },
        watch: {
            dialogState(newVal) {
                this.showDialog = newVal;
                if (newVal) {
                    this.getDependentData();
                }
            }
        }
    };
</script>
<style></style>
